package com.credithc.customers.manager.schedule;

import com.credithc.customers.manager.service.ScheduleService;
import com.credithc.customers.manager.utils.StatsUtils;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author zhukai
 * @date 19/2/15 0015 9:58
 */
@Slf4j
public class StatsPreChangeJob implements Job {

    @Autowired
    private ScheduleService scheduleService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        log.info("=========================================开始统计客户转化率=========================================");
        String currentDay = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        currentDay = StatsUtils.getPastDate(1, currentDay);
        scheduleService.statsPreChange(currentDay);
    }
}
